<template>
  <div>
    <div class="menu" :class="{ drakTheme: route?.meta?.theme == 'dark' || drakTheme }">
      <a-menu v-model:selectedKeys="current" mode="horizontal" @click="menuClick">
        <a-menu-item :key="index + 1" v-for="(item, index) in dataSource">
          <span>{{ item }}</span>
        </a-menu-item>
      </a-menu>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { ref, defineEmits, defineProps, toRefs } from "vue";
import { useRoute } from "vue-router";
const route = useRoute();
const props = defineProps({
  drakTheme: Boolean,
  dataSource: [],
});
const { drakTheme, dataSource } = toRefs(props);
const emits = defineEmits(["change"]);
const current = ref<string[]>([1]);

function menuClick(e): void {
  const { key } = e;
  emits("change", key);
}
</script>

<style lang="less" scoped>
.menu {
  // /deep/ .ant-menu-item {
  //   border: 1px solid #dcdfe6;
  //   border-radius: 5px;
  // }
  &.drakTheme {
    /deep/ .ant-menu {
      color: #fff;
      background: transparent;
      border-bottom: none;
      .ant-menu-item-selected {
        background: transparent;
        border: 1px solid #01cbfe;
      }
      .ant-menu-item-selected::after {
        border-bottom: none;
      }
    }
  }
}
</style>
